package com.lin.csdn.service.impl;

import com.lin.csdn.dao.impl.BlogDao;
import com.lin.csdn.dao.impl.CollectDao;
import com.lin.csdn.dao.impl.UserDao;
import com.lin.csdn.utils.ResultSplit;

import java.util.ArrayList;
import java.util.List;

public class CollectService {

    CollectDao collectDao=new CollectDao();
    UserDao userDao=new UserDao();
    BlogDao blogDao=new BlogDao();
    ResultSplit split=new ResultSplit();

    //获取收藏夹中的博客
    public List<Object> getCollectBlog(String useName){
        int userId=userDao.findId(useName);
        List blogIdList= (List) collectDao.getCollectBlog(userId);
        List<Object> list=new ArrayList<>();
        System.out.println(blogIdList.get(0));
        for (Object blogId : blogIdList) {
            Object result = blogDao.idAllBlog(Integer.parseInt(blogId.toString()));
            String process = result.toString().replace("[", "");
            String data = process.replace("]", "");
            list.add(data);
        }
        List<Object> blog=split.resultSplit(list);
        return blog;
    }
}
